package com.token.iot.bratterycharging.gateway.server;


import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;


public class BratteryChargingThread extends Thread {

	private ChannelFuture future;

	private ServerBootstrap bootstrap;

	private int port;

	public BratteryChargingThread(ChannelFuture future, ServerBootstrap bootstrap, int port) {
		this.future = future;
		this.bootstrap = bootstrap;
		this.port = port;
	}

	@Override
	public void run() {
		try {
			// 服务器绑定端口监听
			future = bootstrap.bind(port).sync();
			// 监听服务器关闭监听，此方法会阻塞
			future.channel().closeFuture().sync();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	public ChannelFuture getFuture() {
		return future;
	}

	public void setFuture(ChannelFuture future) {
		this.future = future;
	}

	public ServerBootstrap getBootstrap() {
		return bootstrap;
	}

	public void setBootstrap(ServerBootstrap bootstrap) {
		this.bootstrap = bootstrap;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

}

